package cate.game.activity.weekcard.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.activity.weekcard.WeekCardActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBWeekCardActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;


@ClientMsg(title = "购买周卡的请求")
@OperationSetter(value=GDOperation.BUY_WEEK_CARD,sub = "tid")
public class BuyWeekCardReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField("周卡ID")
    public int tid;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        WeekCardActivity weekCard= cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (weekCard == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        EcResult<WeekCardActivity> r = weekCard.buyCard(tid);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBWeekCardActivity.BUY_WEEK_CARD_REQ;
    }
}
